

goto = function(des, obj) {
	mui.openWindow({
		url: des,
		extras: {
			orderid: $(obj).data("orderid")
		}
	});
};

hank_evaluate = function(orderId) {
    // evaluateOrder
    $(".popover_Top_active").removeClass("popover_Top_active");
    $(".popover_Bottom_active").removeClass("popover_Bottom_active");
	$("#popover_submit").attr("evaluateData",orderId);
    mui('#popover').popover("toggle");
};

var button_text,button_text_two,button_text_fn,button_text_del,dataOrderType,order_class='',nameType;
addorders = function(data,obj,index_order) {

	for(var key in data) {

		dataOrderType = data[key].fake_id.substring("0","1");

        if(dataOrderType == "A"){
            nameType = "被护理人：";
        }else{
            nameType = "";
        }

		if(index_order == 1){
			button_text = "订单详情";
			button_text_two = "取消订单";
			button_text_del = 'onclick="del_order('+data[key].id+');"';
			button_text_fn = 'data-orderid="'+data[key].id+'" onclick="goto(\'sub_order_detail.html\',this)"';
			order_class = "";
		}else if(index_order == 2){
			button_text = "评价";
			order_class = "evaluate_tap";
			button_text_del = 'data-orderid="'+data[key].id+'" onclick="goto(\'sub_order_detail.html\',this)"';
			button_text_two = "订单详情";
			button_text_fn = 'onclick="hank_evaluate('+data[key].id+')"';
			//console.log(dataOrderType);
		}else if(index_order == 3){
			button_text = "";
			order_class = "hide";
			button_text_two = "订单详情";
			button_text_del = 'data-orderid="'+data[key].id+'" onclick="goto(\'sub_order_detail.html\',this)"';
			//if(dataOrderType == "A"){
			//	order_class = "empty";
			//}else{
			//	order_class = "";
			//}
		}

		//时间戳转日期格式
		var timestart = getLocalTime(data[key].servertime);
		var timestop = getLocalTime(data[key].serverendtime);

		var dom = '<li class="mui-table-view-cell mui-media">' +
						'<a href="javascript:void(0);" class="">' +
							// '<img class="mui-media-object mui-pull-left" src="'+data[key].headurl+'">' +
							'<div class="mui-media-body my-box">' +
								'<p class="Title_Name">'+nameType+data[key].name+'</p>' +
								'<p class="mui-ellipsis Title_Text">时间: '+timestart+'-'+timestop+'</p>' +
								'<p class="Title_Text">地址: '+data[key].city+data[key].detail_adress+'</p>' +
							'</div>' +
						'</a>' +
							'<div class="mui-media-body my-box box-border">' +
								'<p class="Title_Text Title_Left">价格: '+data[key].amount*data[key].price+'元</p>' +
								'<p class="Title_Text Title_Right Title_info '+order_class+'"><button '+button_text_fn+'>'+button_text+'</button></p>' +
								'<p class="Title_Text Title_Right Title_close"><button '+button_text_del+'>'+button_text_two+'</button></p>' +
							'</div>' +
					'</li>';
		$(obj).append(dom);
		//$(".empty").empty();
	}
};

gotoerror = function() {

		var dom = '<div style="text-align:center;margin-top:30px;color:grey;"> \
						订单加载中...请下拉刷新\
					</div>';
		$("#spread").append(dom);

};

function getLocalTime(nS) {
	return  new Date(parseInt(nS) * 1000).Format("yyyy.MM.dd");
}
Date.prototype.Format = function (fmt) { //author: meizz
	var o = {
		"M+": this.getMonth() + 1, //月份
		"d+": this.getDate(), //日
		"h+": this.getHours(), //小时
		"m+": this.getMinutes(), //分
		"s+": this.getSeconds(), //秒
		"q+": Math.floor((this.getMonth() + 3) / 3), //季度
		"S": this.getMilliseconds() //毫秒
	};
	if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
	for (var k in o)
		if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
	return fmt;
};